﻿using System;
using System.Collections.Generic;

using System.Windows;
using System.Windows.Controls;

using System.Windows.Input;
using System.Windows.Navigation;

namespace EagleJournal
{
    public struct POPanelInfo
    {
        public string ID;
        public string Description;
        public string Amount;
        public string Deadline;
        public string Company;
    }

	public partial class PanelOrderInfo : UserControl
    {
        public static readonly  RoutedEvent
            InvokeOrderEditEvent        = EventManager.RegisterRoutedEvent("InvokeClientEdit", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(PanelOrderInfo));
        public event            RoutedEventHandler
            InvokeOrderEdit
        {
            add     { this.AddHandler(InvokeOrderEditEvent, value); }
            remove  { this.RemoveHandler(InvokeOrderEditEvent, value); }
        }

        public static readonly  RoutedEvent
            InvokeOrderClientsEvent     = EventManager.RegisterRoutedEvent("InvokeClientOrders", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(PanelOrderInfo));
        public event            RoutedEventHandler
            InvokeOrderClients
        {
            add     { this.AddHandler(InvokeOrderClientsEvent, value); }
            remove  { this.RemoveHandler(InvokeOrderClientsEvent, value); }
        }

        int PK;

		public              PanelOrderInfo          ()
		{
			this.InitializeComponent();
		}

        private     void    ButtonEdit_Click        (object sender, RoutedEventArgs e)
        {
            this.RaiseEvent(new RoutedEventArgs(InvokeOrderEditEvent));
        }
        private     void    ButtonRemove_Click      (object sender, RoutedEventArgs e)
        {
            EagleJournal.Components.EagleMessageBox.ShowMessageBox("Delete purchase order", "Are you sure you want to delete this purchase order?", MessageBoxImage.Question, MessageBoxButton.YesNo);
        }
        private     void    ButtonClients_Click     (object sender, RoutedEventArgs e)
        {
            this.RaiseEvent(new RoutedEventArgs(InvokeOrderClientsEvent));
        }

        public      void    ClearData               ()
        {
            this.TextDescription.Text   = string.Empty;
            this.TextCompany.Text       = string.Empty;
            this.TextAmount.Text        = string.Empty;
            this.DateDeadline.Text      = string.Empty;
            this.TextSerial.Text        = string.Empty;
        }
        public      void    PassData                (int PK, POPanelInfo info)
        {
            this.PK = PK;

            this.TextDescription.Text   = info.Description;
            this.TextCompany.Text       = info.Company;
            this.TextAmount.Text        = info.Amount;
            this.DateDeadline.Text      = info.Deadline;
            this.TextSerial.Text        = info.ID;
        }
	}
}
